import QtQuick
import QtQuick.Controls
Page{
    id:page
    clip: true

    property alias gradient: row.gradient

    property var grad

    contentItem:
        CardRow {
        id:row
        anchors.verticalCenter: parent.verticalCenter
        model:[
            {img:"",text:"碧蓝航线",url:"qrc:/CustomPage.qml"},
            {img:"",text:"蔚蓝档案",url:"qrc:/CustomPage.qml"},
            {img:"",text:"原神",url:"qrc:/CustomPage.qml"},
            {img:"",text:"崩坏：星穹铁道",url:"qrc:/CustomPage.qml"},
            {img:"qrc:/qt-logo.png",text:"card2",url:"qrc:/CustomPage.qml"},
            {img:"qrc:/qt-logo.png",text:"card3",url:"qrc:/CustomPage.qml"},
            // {img:"qrc:/qt-logo.png",text:"card4",url:"qrc:/CustomPage.qml"},
            // {img:"qrc:/qt-logo.png",text:"card5",url:"qrc:/CustomPage.qml"},

        ]
        // 能下拉时
        onCanPull:(cardItem)=> {
                      // 覆盖卡片位置 记录梯度
                      transitionRect.fillItem(cardItem)
                      grad = cardItem.gradient
                      transitionRect.canPush = false
                  }
        // 取消下拉时
        onCancelPull: {
            // 还原标志 设为不可见
            transitionRect.canPush = false
            transitionRect.visible = false
        }
        // 可以推送时
        onCanPush :{
            // 调整大小覆盖parent
            transitionRect.fillParent()
            transitionRect.canPush = true
        }
        // 推送时
        onPushing:(url) => {
                      if( transitionRect.canPush){
                          const com = Qt.createComponent(url).createObject(page,{gradient:grad})
                          stack.push(com)
                      }

                  }

    }

    Card{
        // 能否push的标志
        property bool canPush: false
        visible: false
        id:transitionRect
        border.width: 4
        border.color: "blue"
        radius: 10
        content: ""
        image: ""
        opacity: 0.5
        gradient: grad

        function fillParent(){
            x=0
            y=0
            angle = 0
            width = parent.width
            height = parent.height
        }

        function fillItem(card){
            x = card.x
            y = card.y
            angle = card.angle
            width = card.width
            height = card.height
            visible = true
        }
    }
}


